<?php
header("content-type:text/html;charset=utf-8");
$city=$_POST['city'];
$sdn=("mysql:host=127.0.0.1;dbname=myexam;charset=utf8");
$pdo=new PDO($sdn,'root','root');
$url="http://api.k780.com:88/?app=weather.future&weaid=$city&&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json";
//print_r($url);die;
$data=file_get_contents($url);
//print_r($data);die;
$data=json_decode($data,true);
//print_r($data);die;
$result=$data['result'];
//print_r($result);die;
foreach($result as $key=>$val)
{
    $citynm=$val['citynm'];
    $week=$val['week'];
    $temp_high=$val['temp_high'];
    $temp_low=$val['temp_low'];
    $temperature=$val['temperature'];
    $sql="insert into tq value(null,'$citynm','$week','$temp_high','$temp_low','$temperature')";
    //print_r($sql);die;
    $res=$pdo->exec($sql);
    //print_r($res);die;
}
    if($res)
    {
        
    }
































